//
//  CTCommentViewController.m
//  cactus
//
//  Created by wd on 11-12-1.
//  Copyright 2011年 ifeng. All rights reserved.
//

#import "CTCommentViewController.h"
#import <QuartzCore/QuartzCore.h>
#import <Foundation/Foundation.h>
#import "CLGloble.h"
#import "CommentCommonCell.h"
#import "PlanningTopicCoreTextLabel.h"
#import "BlockUI.h"
#import "CLComentDataModel.h"
#import "CLGlobleDataModel.h"

#define _loadingColor [UIColor colorWithRed:226.0/255.0 green:231.0/255.0 blue:237.0/255.0 alpha:1.0]
#define version 5.0

#define content_Label_x       5
#define content_Label_y       8
#define content_Label_Width   310//[Globle shareInstance].globleHeight - 150
#define content_Label_Height  18
#define fix_comment_count 70

#define headViewHeight 44

#define content_Background_Origin_Rect      CGRectMake(0, [Globle shareInstance].globleHeight-39, 320, 10+10+18)

#define PPSystemVersionGreaterOrEqualThan(version) ([[[UIDevice currentDevice] systemVersion] floatValue] >= version)

#import "CLGloble.h"

@interface CTCommentViewController()
@property (nonatomic, strong) NSString *pathID;
@property (nonatomic, strong) UIImageView *bottomView;
@property (nonatomic, strong) UIView *headBaseView;
@property (nonatomic, strong) UIButton *headBackBtn;
@property (nonatomic, strong) UILabel *headTitleLab;
@property (nonatomic, strong) UIView *headSepertorLine;
@property (nonatomic, strong) UIView *stateBarView;

- (int)getNumOfLine:(int) width  rectWidth:(int) rectWidth;
- (void)setUpAssisntView;
- (void)setassistantViewStatuwithLocateInWindow:(CGPoint)locateInWindow
                               withLocateInCell:(CGPoint)locateInCell
                                 withSizeOfCell:(CGSize)sizeOfCell
                                      withLevel:(NSNumber *)level
                                     needHidden:(BOOL)isHidden;
-(void)createalertHeaderView;
@end

@implementation CTCommentViewController
@synthesize wwwUrl,commentType,uuid,currentTitle,docTitle,ip,headerView,ctContent,headerLabel,is4Push,isReplayComment,documentId;
@synthesize alertHeaderView,alertHeaderLabel;
@synthesize assistantView;
@synthesize currentCommentSourceData;
@synthesize hottestComments,docUrl;
@synthesize selectedIndexPath;
@synthesize floorParrentsArrayIndex;
@synthesize cellLevel;
@synthesize supportedIndexPaths;
@synthesize waitingView;
@synthesize isNavgShowed;

//- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
//{
//    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
//    if (self) {
//        is4Push=NO;
//        objectId=[INThreadDelegate createID];
//        [objectId retain];
//        [INThreadDelegate addDelegate:self forKey:objectId];
//    }
//    return self;
//}

-(id)init{
    self=[super init];
    if (self) {
        is4Push=NO;
        self.isNeedRequest=YES;
        self.pageComment = NO;
    }
    
    return self;
}


#pragma mark - Stat
- (void)setSuperPathID:(NSString *)pathID
{
    self.pathID = pathID;
}

- (BOOL)showPopAction{
    return YES;
}



#pragma mark -


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.view.frame=CGRectMake(0, 0, 320, GlobleHeight);
    self.view.backgroundColor = RGB(0xf7, 0xf7, 0xf7);

    self.isReplayComment = NO;
    self.strCurrentComment = nil;
    //self.shareType=noneType;
    [self initialization];
    if (![self isPageComment]) {
//        [self addNavagationButton];
    }
    [self updateCSS];
    if(self.responseObject){
        [ctContent setCommentData:self.responseObject];
    }else
        if(self.isNeedRequest){
            [self initWithData:self.wwwUrl];
        }
    
}

- (void)viewDidAppear:(BOOL)animated
{
    // [self initWithData:self.wwwUrl];
    //[self navigatorView];
    
   
}

- (void)updateCSS
{
    ;
}

-(void)notResign{
    
}
-(void)ctCountCount:(int)count{
    
}
#pragma mark - 自定义导航栏


/*
- (void)addNavagationButton{
    [self.ctContent.panGestureRecognizer addTarget:self action:@selector(navgRecognizer:)];
    self.backButton=[BackButton7Black createBackButton];
    self.backButton.isComment = YES;
    [self.view addSubview:self.backButton];
    self.isNavgShowed=YES;
    self.buttontPannel=[Button7PannelBlack button7PannelBlackOnlyComment:self];
    [self.view addSubview:self.buttontPannel];
    
}
*/
- (void)showCommentDic:(NSDictionary *)commentsDic{
    self.responseObject=commentsDic;
    [self.ctContent setCommentData:commentsDic];
}

- (void)setCommentsURL:(NSString *)commentsURl{
    self.ctContent.wwwUrl=commentsURl;
}

-(void)setCommentFail{
    [self.ctContent setCommentFail];
}
/*
//自定义导航按钮
- (NSArray *)getcustomNavigationItems{
    NSMutableArray *arr=[[NSMutableArray alloc] init];
    
    IfengNewsButton *commentBtn=[IfengCommentingButton createButton:navigator_bottom_btn_rect(240)];
    commentBtn.datasource=self;
    commentBtn.isCommentPage = YES;
    
    [arr addObject:commentBtn];
    return arr;
}
*/
#pragma mark -
#pragma mark --跳转的代理方法 DispatchCenter.h UIViewControllerDispatchable

//- (void)willPush:(DispatchCenter *)dispatchCenter{
//    id entity = [dispatchCenter getParam:@"entity"];
//    if (!entity || ![entity isKindOfClass:[NSDictionary class]]) {
//        return;
//    }
//    self.wwwUrl= (NSString *)[entity sgrObjectForKey:@"wwwUrl"];
//    self.docTitle = (NSString *)[entity sgrObjectForKey:@"docTitle"];
//    self.commentType = (NSString *)[entity sgrObjectForKey:@"commentType"];
//    self.currentTitle =  (NSString *)[entity sgrObjectForKey:@"currentTitle"];
//    self.docUrl = (NSString *)[entity sgrObjectForKey:@"commentUrl"];
//    self.docBody = (CKDocBody *)[entity sgrObjectForKey:@"docBody"];
//    self.documentId = [entity sgrGetStringForKey:@"documentId"];
//    self.docLinkUrl = (NSString *)[entity sgrObjectForKey:@"docUrl"];
//    self.docType = (NSString *)[entity sgrObjectForKey:@"docType"];
//}
//
//- (void)didPush:(DispatchCenter *)dispatchCenter{
//    NSDictionary *dic=[dispatchCenter dictionaryFromParam:@"commentDic"];
//    if (dic) {
//        [self.ctContent initMyComments:NO];
//    }
//    else{
//        [self.ctContent initMyComments:YES];
//    }
//    if(dic){
//        [self showCommentDic:dic];
//    }
//}
//
//- (void)willPop:(DispatchCenter *)dispatchCenter{
//}
//
//- (void)didPop:(DispatchCenter *)dispatchCenter{
//    
//}
#pragma mark -

- (void)viewWillAppear:(BOOL)animated{
    if (is4Push) return;
    
    //   [[CTCollectViewController shareInstance] hiddenEdit];
}

-(void)viewWillDisappear:(BOOL)animated{
    //以免当inputView还在显示，而ViewController Disappear
//    if (self.inputView) {
//        [self.inputView resign];
//    }
}

//-(void)back{
//    [UIView beginAnimations:nil context:nil];
//    [UIView setAnimationDuration:0.2f];
//    [UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
//    [UIView commitAnimations];
//    cactusAppDelegate *onlyDelegate =
//    (cactusAppDelegate *)[UIApplication sharedApplication].delegate;
//    [onlyDelegate.topNavigation popViewControllerAnimated:YES];
//
//}

#pragma mark -初始化
-(void)initialization{
    [self createStatuView];
    //[self createHeadView];
    [self createTable];
    [self initWaitingView];
    [self createBottomView];
}

- (void)createStatuView
{
   
        UIImageView *stateBarView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 20)];
        stateBarView.backgroundColor = RGB(0xf6, 0xf6, 0xf6);
        [self.view addSubview:stateBarView];
        self.stateBarView = stateBarView;
    
}
- (void)createBottomView
{
    UIImageView *bottomView = [UIImageView new];
    bottomView.frame = CGRectMake(0, ctContent.frame.size.height+ctContent.frame.origin.y, GlobleWidth, 44);
    bottomView.backgroundColor = RGB(0xf6, 0xf6, 0xf6);
    bottomView.image = [UIImage imageNamed:@"comment_bottom.png"];
    bottomView.userInteractionEnabled = YES;
    self.bottomView = bottomView;
    [self.view addSubview:bottomView];
    
    UIButton *back=[UIButton buttonWithType:UIButtonTypeCustom];
    back.frame=CGRectMake(13.f, 7.f, 30.f, 30.f);
    back.contentEdgeInsets=UIEdgeInsetsMake(3, 3, 3, 3);
    [back setImage:[UIImage imageNamed:@"tb_back.png"]
          forState:UIControlStateNormal];
    [bottomView addSubview:back];
    __weak typeof(self) me=self;
    [back handleControlEvent:UIControlEventTouchUpInside withBlock:^(id sender) {
        [me.dispatchObj pop];
        //[DispatchCenter pop];
    }];
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapComment:)];
    tap.numberOfTapsRequired = 1;
    tap.numberOfTouchesRequired = 1;
    [bottomView addGestureRecognizer:tap];
    
}

- (void)reloadHeaderView
{
    if(!self.headBaseView || !self.headTitleLab || !self.headBackBtn || !self.headSepertorLine)
        return;
    
    self.headBaseView.backgroundColor = RGB(0xf6, 0xf6, 0xf6);
    self.headTitleLab.textColor = RGB(0x5e, 0x64, 0x75);
    [self.headBackBtn setBackgroundImage:[UIImage imageNamed:@"comment_head_back.png"] forState:UIControlStateNormal];
    //[self.headBackBtn setBackgroundImage:ICurrentTheme.commentStyle.commentHeadBackHightImg forState:UIControlStateHighlighted];
    self.headSepertorLine.backgroundColor = RGB(0xc1, 0xc1, 0xc1);
    
}

- (void)reloadStatuView
{
    self.stateBarView.backgroundColor = RGB(0xf6, 0xf6, 0xf6);
}

- (void)reloadBottomView
{
    if(!self.bottomView)
        return;
    
    self.bottomView.image = [UIImage imageNamed:@"comment_cancel_new.png"];
    self.bottomView.backgroundColor = RGB(0xf6, 0xf6, 0xf6);
}

//- (void)createHeadView
//{
//    UIView *headBaseView = [UIView new];
//    headBaseView.frame = CGRectMake(0, 0, 320,headViewHeight);
//    headBaseView.backgroundColor = RGB(0xf6, 0xf6, 0xf6);
//    
//    UILabel *titleLabel = [UILabel new];
//    titleLabel.backgroundColor = [UIColor clearColor];
//    titleLabel.frame = CGRectMake(0, 23, 150, 18);
//    titleLabel.textAlignment = NSTextAlignmentCenter;
//    titleLabel.center = CGPointMake(headBaseView.center.x, titleLabel.frame.origin.y);
//    titleLabel.font = [UIFont boldSystemFontOfSize:18];
//    titleLabel.textColor = RGB(0x5e, 0x64, 0x75);
//    titleLabel.text = @"评论";
//    self.headTitleLab = titleLabel;
//    [headBaseView addSubview:titleLabel];
//    
//    UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
//    backBtn.frame = CGRectMake(8, CGRectGetHeight(headBaseView.frame) - 28 - 8, 28, 28);
//    [backBtn setBackgroundImage:ICurrentTheme.commentStyle.commentHeadBackNormalImg forState:UIControlStateNormal];
//    [backBtn setBackgroundImage:ICurrentTheme.commentStyle.commentHeadBackHightImg forState:UIControlStateHighlighted];
//    [backBtn addTarget:self action:@selector(goBack) forControlEvents:UIControlEventTouchUpInside];
//    self.headBackBtn = backBtn;
//    [headBaseView addSubview:backBtn];
//    
//    UIView *line = [UIView new];
//    line.frame = CGRectMake(0, headViewHeight - 0.5, CGRectGetWidth(headBaseView.frame), 0.5);
//    line.backgroundColor = ICurrentTheme.commentStyle.sepertorLineColor;
//    self.headSepertorLine = line;
//    [headBaseView addSubview:line];
//    
//    self.headBaseView = headBaseView;
//    
//    [self.view addSubview:headBaseView];
//}

- (void)goBack
{
   // [DispatchCenter pop];
}

- (void)setscrolltoTop:(BOOL)top{
    ctContent.table.scrollsToTop=top;
}

-(void)createTable{
    ctContent = [[CTCommentTable alloc] initWithFrame:CGRectMake(0, 20, 320,(GlobleHeight-20-44))];
    ctContent.table.separatorStyle = UITableViewCellSeparatorStyleNone;
    ctContent.table.backgroundColor = RGB(0xf7, 0xf7, 0xf7);
    UIView *bg=[UIView new];
    bg.backgroundColor=RGB(0xf7, 0xf7, 0xf7);
    ctContent.table.backgroundView=bg;
    
    ctContent.uuid = self.uuid;
    ctContent.wwwUrl = self.wwwUrl;
    ctContent.documentId = @"";
   // ctContent.hidden = YES;
    ctContent.ctDelegate = self;
   // ctContent.userInteractionEnabled = YES;
   // [self.ctContent initMyComments:NO];
    [self.view addSubview:ctContent];
    if(![self.ctContent hasCommentData])
    {
        [self.ctContent.table reloadData];
        [waitingView stopAnimating];
    }
}

- (void)initWaitingView
{
    waitingView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
    waitingView.frame = CGRectMake(160, (GlobleHeight-44)/2+44-37, 20, 20);
    waitingView.center = CGPointMake(160,(GlobleHeight-44)/2+44-37);
    waitingView.backgroundColor = [UIColor clearColor];
    [self.view addSubview:waitingView];
    [self.view bringSubviewToFront:waitingView];
}

//- (void)initBackGroundView
//{
//    backGroundView = [[UIView alloc] initWithFrame:self.view.frame];
//    backGroundView.backgroundColor = [UIColor clearColor];
//    [backGroundView setTag:9527];
//    [self.view addSubview:backGroundView];
//    backGroundView.hidden = YES;
//    
//    errorButton = [[IfengStateButton alloc] init];
//    errorButton.frame = CGRectMake(0, 0, 200, 112);
//    errorButton.center = CGPointMake([Globle shareInstance].globleWidth/2, [Globle shareInstance].globleHeight/2-55);
//    errorButton.backgroundColor = [UIColor clearColor];
//    
//    [errorButton setButtonstateError];
//    
//    [errorButton addTarget:self action:@selector(restBtPressed:) forControlEvents:UIControlEventTouchUpInside];
//    [backGroundView addSubview:errorButton];
//}

//- (void)restBtPressed:(IfengStateButton *)sender
//{
//    //待定
//    backGroundView.hidden = YES;
//    // [ctContent initWithData];
//}

- (void)tapComment:(UIGestureRecognizer *)aRecognizer
{
    if(![[CLGloble sharedInstance] checkOnLine]){
        [[CLGloble sharedInstance] showTieAlertMessage:@"提示" subMessage:@"无网络连接"];
       // [BlockerView showAlert:@"无网络链接"];
        return;
    }
    self.isReplayComment = NO;
    [self showCommentingView];
}

#pragma mark
#pragma mark -评论代理-
- (void)getCommentForInDocViewWith:(NSDictionary *)entity
{
    if (!entity || ![entity isKindOfClass:[NSDictionary class]]) {
        
        [ctContent.table reloadData];
        return;
    }
    self.wwwUrl= (NSString *)[entity sgrObjectForKey:@"wwwUrl"];
    self.docTitle = (NSString *)[entity sgrObjectForKey:@"docTitle"];
    self.commentType = (NSString *)[entity sgrObjectForKey:@"commentType"];
    self.currentTitle =  (NSString *)[entity sgrObjectForKey:@"currentTitle"];
    self.docUrl = (NSString *)[entity sgrObjectForKey:@"commentUrl"];
    
    ctContent.wwwUrl = self.wwwUrl;
    
}

-(void)initWithData:(NSString *)url{
    
    [ctContent initWithData];
}

- (void)getCurrentIP
{
//    @autoreleasepool {
//        NSURL *url = [NSURL URLWithString:[[Globle shareInstance] getAbsolutlyUrlById:@"getIP"]];
//        NSURLRequest *request = [NSURLRequest requestWithURL:url];
//        NSURLResponse __autoreleasing *response = nil;
//        NSError __autoreleasing *error = nil;
//        NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
//        NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
//        if (responseString) {
//            NSString *_ip = [NSString stringWithFormat:@"%@", responseString];
//            self.ip = _ip;
//            
//        }
//    }
}

- (void)setDocEntity:(NSDictionary *)entity{
    self.docTitle=[entity sgrGetStringForKey:@"title"];
    self.wwwUrl = [entity sgrGetStringForKey:@"url"];
    self.documentId = [entity sgrGetStringForKey:@"documentId"];
    
    self.commentType = (NSString *)[entity sgrObjectForKey:@"commentType"];
    self.currentTitle =  (NSString *)[entity sgrObjectForKey:@"currentTitle"];
    self.docUrl = (NSString *)[entity sgrObjectForKey:@"commentUrl"];
    self.docLinkUrl = (NSString *)[entity sgrObjectForKey:@"docUrl"];
    self.docType = (NSString *)[entity sgrObjectForKey:@"docType"];
   // self.docBody = (CKDocBody *)[entity sgrObjectForKey:@"docBody"];
    
}
#pragma mark -
#pragma mark - 评论后同时分享
//-(void)shareAfterSendComment{
//    NSString *dateStr = [NSString stringFromDate:[NSDate date]];
//    NSMutableDictionary *dataDic = [[NSMutableDictionary alloc] init];
//    [dataDic sgrSetObject:self.strCurrentComment forKey:@"comment_contents"];
//    [dataDic sgrSetObject:dateStr forKey:@"comment_date"];
//    if ([Globle shareInstance].userTokenAvailability) {
//        [dataDic sgrSetObject:[Globle shareInstance].userEntity.userImage forKey:@"userFace"];
//        [dataDic sgrSetObject:(_isStrNotNull([Globle shareInstance].userEntity.userNickName)?[Globle shareInstance].userEntity.userNickName:@"客户端用户") forKey:@"uname"];
//    }
//    else{
//        [dataDic sgrSetObject:@"" forKey:@"userFace"];
//        [dataDic sgrSetObject:@"客户端用户" forKey:@"uname"];
//    }
//    [dataDic sgrSetObject:@"0" forKey:@"uptimes"];
//    
//    CKDocBody *commentDocBody = [[CKDocBody alloc] init];
//    commentDocBody.title = _isStrNotNull(self.docBody.title)?(self.docBody.title):(self.docTitle);
//    commentDocBody.linkType = self.docBody.linkType;
//    commentDocBody.strShareUrl = _isStrNotNull(self.docBody.strShareUrl)?(self.docBody.strShareUrl):(self.wwwUrl);
//    commentDocBody.thumbnail = nil;//self.docBody.thumbnail;
//    commentDocBody.type = DocBodyTypeComments;
//    commentDocBody.documentId = _isStrNotNull(self.docBody.documentId)?(self.docBody.documentId):(self.documentId);
//    commentDocBody.text = [NSString stringWithFormat:@"网友评论:%@",_isStrNotNull(self.strCurrentComment)?self.strCurrentComment:@""];
//    commentDocBody.isComment = YES;
//    [CommentShareCaputreImgHandle createCompleteShareImage:dataDic title:commentDocBody.title floorImg:[IFShareDelegateObject sharedInstance].currentShareImage];
//    commentDocBody.captureImg=[IFShareDelegateObject sharedInstance].currentShareImage;
//    commentDocBody.imgArray = nil;
//    [CTShareController shareDirectly:self.shareType rootView:[cactusAppDelegate ctWindow] dataBean:commentDocBody];
//    
//    self.strCurrentComment = nil;
//    self.shareType=noneType;
//    
//}

#pragma mark -
#pragma mark - InputViewDelegate
-(void)postComment:(NSString *)content :(NSNumber *)beSelect{
    __weak typeof(self) me=self;
    if(self.isReplayComment){
        NSString *replayCommentId = [self.currentCommentSourceData sgrFoceGetStringForKey:@"comment_id" defaultValue:@""];
        //NSLog(@"%@",replayCommentId);
        
        [[CLComentDataModel sharedInstance] submitCommentWithTopicId:self.commentTopicId
                                                             content:content
                                                             replyID:replayCommentId
                                                               block:^(BOOL success, NSString *commentId) {
                                                                   if(success){
                                                                        [[CLGloble sharedInstance] showTieAlertMessage:@"提示"
                                                                                                                                                                 subMessage:@"回复成功"];
                                                                       
                                                                       
                                                                       NSString *str=[NSString stringWithFormat:@"我的评论:%@ |%@ %@",_safeStr(content),_safeStr(me.docTitle),
                                                                                      _safeStr(me.shareUrl)];
                                                                       [[CLGlobleDataModel sharedInstance] shareMessage:[beSelect intValue] content:str];

                                                                    }else{
                                                                                                        [[CLGloble sharedInstance] showTieAlertMessage:@"提示"
                                                                                                                                                                 subMessage:@"回复失败"];
                                                                       
                                                                                                                    }
                                                               }];
    }else{
        [[CLComentDataModel sharedInstance] submitCommentWithTopicId:self.commentTopicId
                                                             content:content
                                                             replyID:nil
                                                               block:^(BOOL success, NSString *commentId) {
                                                                   if(success){
                                                                       [[CLGloble sharedInstance] showTieAlertMessage:@"提示"
                                                                                                           subMessage:@"发送成功"];
                                                                       NSString *str=[NSString stringWithFormat:@"我的评论:%@ |%@ %@",_safeStr(content),_safeStr(me.docTitle),
                                                                                      _safeStr(me.shareUrl)];
                                                                       [[CLGlobleDataModel sharedInstance] shareMessage:[beSelect intValue] content:str];
                                                                   }else{
                                                                       [[CLGloble sharedInstance] showTieAlertMessage:@"提示"
                                                                                                           subMessage:@"发送失败"];
                                                                       
                                                                   }
                                                               }];

    }
    

}

//-(void)localMyCommentHandle:(NSString *)commentContent isReply:(NSString *)isReplay{
//    NSString *dateStr = [NSString stringFromDate:[NSDate date]];
//    NSMutableDictionary *dataDic = [[NSMutableDictionary alloc] init];
//    [dataDic sgrSetObject:commentContent forKey:@"comment_contents"];
//    [dataDic sgrSetObject:dateStr forKey:@"comment_date"];
//    if ([Globle shareInstance].userTokenAvailability) {
//        [dataDic sgrSetObject:[Globle shareInstance].userEntity.userImage forKey:@"userFace"];
//        [dataDic sgrSetObject:(_isStrNotNull([Globle shareInstance].userEntity.userNickName)?[Globle shareInstance].userEntity.userNickName:@"客户端用户") forKey:@"uname"];
//        
//        NSMutableDictionary *ext2 = [NSMutableDictionary new];
//        [ext2 sgrSetObject:@"" forKey:@"docId"];
//        [ext2 sgrSetObject:@"sj" forKey:@"from"];
//        [ext2 sgrSetObject:[Globle shareInstance].userEntity.userGUID forKey:@"guid"];
//        [ext2 sgrSetObject:@"doc" forKey:@"type"];
//        [ext2 sgrSetObject:[Globle shareInstance].userEntity.userNickName forKey:@"nickname"];
//        
//        NSString *ext2Str = [ext2 JSONString];
//        [dataDic sgrSetObject:ext2Str forKey:@"ext2"];
//        
//    }
//    else{
//        [dataDic sgrSetObject:@"" forKey:@"userFace"];
//        [dataDic sgrSetObject:@"客户端用户" forKey:@"nickname"];
//    }
//    [dataDic sgrSetObject:@"0" forKey:@"uptimes"];
//    if ([isReplay isEqualToString:@"YES"]) {
//        NSMutableDictionary *replayDic = [[NSMutableDictionary alloc] init];
//        [replayDic sgrSetObject:[self.currentCommentSourceData sgrGetStringForKey:@"comment_contents"] forKey:@"comment_contents"];
//        [replayDic sgrSetObject:[self.currentCommentSourceData sgrGetStringForKey:@"uname"] forKey:@"nickname"];
//        [replayDic sgrSetObject:[self.currentCommentSourceData sgrGetStringForKey:@"ip_from"] forKey:@"ip_from"];
//        [replayDic sgrSetObject:[self.currentCommentSourceData sgrGetStringForKey:@"ext2"] forKey:@"ext2"];
//        NSArray *parentArray = [[NSArray alloc] initWithObjects:replayDic, nil];
//        [dataDic sgrSetObject:parentArray forKey:@"parent"];
//    }
//    
//    NSString *dataDicStr = [dataDic JSONString];
//    MyCommentEntityModel *model = [[MyCommentEntityModel alloc] initWithDocumentId:(self.docBody.documentId?self.docBody.documentId:self.documentId)  comment_data:dataDicStr comment_date:dateStr uniqueId:@"" isReply:isReplay];
//    [[MyCommentService shareInstance] saveWithEntity:model withCompleteBlock:(MyCommentServiceEditCompleteBlock)^(BOOL resut){
//        [[Globle shareInstance] setmyCommentCountDicWith:(self.docBody.documentId?self.docBody.documentId:self.documentId) key:dateStr];
//        [self.ctContent reloadData];
//    }];
//    
//    if (dataDic) {
//        [self.ctContent.myComments sgrInsertObject:dataDic atIndex:0];
//        [self.ctContent tableReloadData];
//        if ([isReplay isEqualToString:@"NO"]) {
//            NSUInteger indices[] = {1, 0};
//            NSIndexPath *_indexPath = [[NSIndexPath alloc] initWithIndexes:indices length:2];
//            [self.ctContent scrollToRowAtIndexPath:_indexPath atScrollPosition:UITableViewScrollPositionMiddle animated:YES];
//        }
//    }
//}
//验证ip合法
- (BOOL)isValidatIP:(NSString *)ipAddress{
    
    if(!ipAddress || ![ipAddress isKindOfClass:[NSString class]] || [ipAddress length] <= 0)
        return NO;
    
    NSString  *urlRegEx =@"^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\."
    "([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\."
    "([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\."
    "([01]?\\d\\d?|2[0-4]\\d|25[0-5])$";
    
    NSPredicate *urlTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", urlRegEx];
    return [urlTest evaluateWithObject:ipAddress];
}




-(void)showNetErrorAlert:(NSString *)message
{
    //    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:message delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
    //    [alert show];
    [[CLGloble sharedInstance] showTieAlertMessage:@"提示" subMessage:nil];

   // [self showAlertWithTitle:@"提示" message:message block:nil cancelButtonTitle:@"确定" confirmButtonTitles:nil];
}

//发送成功后的提示
-(void)issueSucceed:(NSString *)content{
    [[CLGloble sharedInstance] showTieSuccessMessage:@"评论" subMessage:@"发送成功!"];
    //[BlockerView showSuccessWithcommentSend];
//    [self localMyCommentHandle:self.strCurrentComment isReply:self.isReplayComment?@"YES":@"NO"];
//    if (self.shareType!=noneType) {
//        [self performSelector:@selector(shareAfterSendComment) withObject:nil afterDelay:0.3];
//    }
//    else{
//        self.strCurrentComment = nil;
//        self.shareType=noneType;
//    }
}
//发送失败后的提示
-(void)issueFailed:(NSString *)content{
    //[BlockerView showFailWithcommentSend];
    [[CLGloble sharedInstance] showTieAlertMessage:@"提示" subMessage:@"评论发送失败!"];
}

-(void)showAlertHeaderView:(NSString *)message
{
    if (!alertHeaderView) {
        [self createalertHeaderView];
    }
    if (NO==alertHeaderView.hidden && 1.0f == alertHeaderView.alpha) {
        return;
    }
    alertHeaderLabel.text = message;
    [self showView:alertHeaderView];
    [self performSelector:@selector(hiddenView:) withObject:alertHeaderView afterDelay:1.5];
}

-(void)showView:(UIView *)view
{
    view.hidden = NO;
    view.alpha = 0.0f;
    [UIView beginAnimations:@"fadeIn" context:nil];
    [UIView setAnimationDuration:0.3];
    view.alpha = 1.0f;
    [UIView commitAnimations];
}

-(void)hiddenView:(UIView *)view
{
    if (view.alpha < 1) {
        return;
    }
    view.alpha = 1.0f;
    [UIView beginAnimations:@"fadeIn" context:nil];
    [UIView setAnimationDuration:0.3];
    view.alpha = 0.0f;
    [UIView commitAnimations];
}


//创建顶部提示浮框
-(void)createalertHeaderView
{
    //初始化的提示浮框
    alertHeaderView = [[UIView alloc] initWithFrame:CGRectMake(10, 59, 299, 54)];
    alertHeaderView.backgroundColor = [UIColor blackColor];
    UIImageView *backgroundImg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"comment_sendComment_alertBackGroung.png"]];
    backgroundImg.frame = CGRectMake(0, 0, alertHeaderView.frame.size.width, alertHeaderView.frame.size.height);
    [alertHeaderView addSubview:backgroundImg];
    alertHeaderLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, alertHeaderView.frame.size.width, alertHeaderView.frame.size.height)];
    alertHeaderLabel.backgroundColor = [UIColor blackColor];
    alertHeaderLabel.text = @"您的评论在路上，稍后即到";
    alertHeaderLabel.textAlignment = NSTextAlignmentCenter;
    alertHeaderLabel.textColor = [UIColor whiteColor];
    [alertHeaderView addSubview:alertHeaderLabel];
    [self.view addSubview:alertHeaderView];
    alertHeaderView.hidden = YES;
}

#pragma mark - 发送评论网络返回代理
-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error{
    [self issueFailed:nil];
}
- (void)connection:(NSURLConnection *)aConn didReceiveResponse:(NSURLResponse *)response{
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{
    NSString *responseStr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
    if(responseStr)
    {
        if(responseStr && [responseStr isEqualToString:@"1"])
            [self issueSucceed:nil];
        else
            [self issueFailed:nil];
    }
    else
        [self issueFailed:nil];
    
}

- (void)viewDidUnload
{
    [super viewDidUnload];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

#pragma mark -
#pragma mark Replay Comments Methods
- (void)addassistantViewwithLocateInWindow:(CGPoint)locateInWindow
                          withLocateInCell:(CGPoint)locateInCell
                            withSizeOfCell:(CGSize)sizeOfCell
                             withIndexPath:(NSIndexPath *)indexPath
                         withSourceDataDic:(NSDictionary *)sourceData
                       atParentsArrayIndex:(NSInteger)parentsArrayIndex
                                 withLevel:(NSNumber *)level
                                  withView:(UIView *)view;
{
    currentClickedPoint = locateInWindow;
    self.currentCommentSourceData = sourceData;
    self.selectedIndexPath = indexPath;
    self.floorParrentsArrayIndex = parentsArrayIndex;
    self.cellLevel = level;
    self.captureImg=[[CLGloble sharedInstance] captureView:view];
    [self performSelector:@selector(setUpAssisntView)];
    
    BOOL needHidden = NO;
    if(self.assistantView.alpha <= 0)
        needHidden = NO;
    else
        needHidden = YES;
    
    [self setassistantViewStatuwithLocateInWindow:locateInWindow withLocateInCell:locateInCell withSizeOfCell:sizeOfCell withLevel:level needHidden:needHidden];
}

- (void)setUpAssisntView
{
    if(self.assistantView)
        return;
    
    UIImageView *view = [[UIImageView alloc] init];
    view.userInteractionEnabled = YES;
    view.backgroundColor = [UIColor clearColor];
    view.frame = CGRectMake(0, 0, 220, 64);
    
    UIImageView *bgView = [[UIImageView alloc] init];
    bgView.userInteractionEnabled = YES;
    bgView.tag = 4545;
    bgView.image = [UIImage imageNamed:@"comment_assis_bg.png"];
    bgView.backgroundColor = [UIColor clearColor];
    bgView.frame = CGRectMake(0, 0, 220, 64);
    [view addSubview:bgView];
    
    UIImageView *arrowView = [[UIImageView alloc] init];
    arrowView.tag = 4546;
    arrowView.image = [UIImage imageNamed:@"comment_assist_arrow_down.png"];
    arrowView.backgroundColor = [UIColor clearColor];
    arrowView.frame = CGRectMake((220)/2-7, 64, 12, 7);

    [view addSubview:arrowView];
    
    //支持
    UIButton *supportButton = [UIButton buttonWithType:UIButtonTypeCustom];
    supportButton.backgroundColor = [UIColor clearColor];
    supportButton.frame = CGRectMake(0, 0, 55, 56);
    [supportButton setBackgroundImage:[UIImage imageNamed:@"comment_assist_support.png"] forState:UIControlStateNormal];
    [supportButton setBackgroundImage:[UIImage imageNamed:@"comment_assist_support_highted.png"] forState:UIControlStateHighlighted];
    [supportButton addTarget:self action:@selector(supportClicked:)
            forControlEvents:UIControlEventTouchUpInside];
    [bgView addSubview:supportButton];
    
    UIImageView *supportIcon = [[UIImageView alloc]initWithFrame:CGRectMake(18, 11, 18, 18)];
    [supportIcon setImage:[UIImage imageNamed:@"comment_assist_replay.png"]];
    
    
    //回复
    UIButton *replayButton = [UIButton buttonWithType:UIButtonTypeCustom];
    replayButton.backgroundColor = [UIColor clearColor];
    replayButton.frame = CGRectMake(55, 0,55, 56);
    [replayButton setBackgroundImage:[UIImage imageNamed:@"comment_assist_replay.png"] forState:UIControlStateNormal];
    [replayButton setBackgroundImage:[UIImage imageNamed:@"comment_assist_replay_highted.png"] forState:UIControlStateHighlighted];
    [replayButton addTarget:self action:@selector(replayPressed:)
           forControlEvents:UIControlEventTouchUpInside];
    [bgView addSubview:replayButton];
    
    
    //分享
    UIButton *shareButton = [UIButton buttonWithType:UIButtonTypeCustom];
    shareButton.backgroundColor = [UIColor clearColor];
    shareButton.frame = CGRectMake(55*2, 0,55, 56);
    [shareButton setBackgroundImage:[UIImage imageNamed:@"comment_assist_share.png"] forState:UIControlStateNormal];
    [shareButton setBackgroundImage:[UIImage imageNamed:@"comment_assist_share_highted.png"] forState:UIControlStateHighlighted];
    [shareButton addTarget:self action:@selector(sharePressed:)
          forControlEvents:UIControlEventTouchUpInside];
    [bgView addSubview:shareButton];
    
    
    //复制
    UIButton *copyButton = [UIButton buttonWithType:UIButtonTypeCustom];
    copyButton.backgroundColor = [UIColor clearColor];
    copyButton.frame = CGRectMake(55*3, 0, 55, 56);
    [copyButton setBackgroundImage:[UIImage imageNamed:@"comment_assist_copy.png"] forState:UIControlStateNormal];
    [copyButton setBackgroundImage:[UIImage imageNamed:@"comment_assist_copy_highted.png"] forState:UIControlStateHighlighted];
    [copyButton addTarget:self action:@selector(copyPressed:)
          forControlEvents:UIControlEventTouchUpInside];
    [bgView addSubview:copyButton];
    
    [self.view addSubview:view];
    [self.view bringSubviewToFront:view];
    self.assistantView = view;
    self.assistantView.alpha = 0.0;
    
}
-(BOOL)directionOfSetassistantViewFrameWithLocateInWindow:(CGPoint)locateInWindow
                                         withLocateInCell:(CGPoint)locateInCell
                                           withSizeOfCell:(CGSize)sizeOfCell
                                                withLevel:(NSNumber *)level{
    BOOL isDown = YES;
    float viewOriginY = locateInWindow.y;
    //level为1表示总共一层当前评论，2表示有盖楼层以前的评论，floorParrentsArrayIndex为0表示盖楼cell的最底层，floorParrentsArrayIndex>0表示盖楼层
    //  if (1|| 1==[level intValue] || (2==[level intValue] && self.floorParrentsArrayIndex>0)) {
    if (locateInWindow.y-locateInCell.y>=45) {
        isDown = YES;
        viewOriginY = locateInWindow.y-locateInCell.y-35;
    }
    else{
        isDown = NO;
        if (sizeOfCell.height-locateInCell.y < 35) {
            viewOriginY = locateInWindow.y-(35-(sizeOfCell.height-locateInCell.y));
        }
    }
    //  }
    
    self.assistantView.frame = CGRectMake((320.0-254)/2,viewOriginY, self.assistantView.frame.size.width, self.assistantView.frame.size.height);
    
    return isDown;
}
- (void)setassistantViewStatuwithLocateInWindow:(CGPoint)locateInWindow
                               withLocateInCell:(CGPoint)locateInCell
                                 withSizeOfCell:(CGSize)sizeOfCell
                                      withLevel:(NSNumber *)level
                                     needHidden:(BOOL)isHidden{
    
    float alpha = 0.0;
    if(isHidden){
        alpha = 0.0;
    }
    else{
        alpha = 1.0;
        BOOL isDown = [self directionOfSetassistantViewFrameWithLocateInWindow:locateInWindow withLocateInCell:locateInCell withSizeOfCell:sizeOfCell withLevel:level];
        float bgViewOriginY = 0;
        float arrowOriginY = 36;
        UIImage *arrowImg = [UIImage imageNamed:@"comment_assist_arrow_down_night.png"];
        if (!isDown) {
            bgViewOriginY = 10;
            arrowOriginY = 0;
            arrowImg = [UIImage imageNamed:@"comment_assist_arrow_up.png"];
        }
        UIView *bgView = [self.assistantView viewWithTag:4545];
        if (bgView) {
            CGRect frame = bgView.frame;
            frame.origin.y = bgViewOriginY;
            bgView.frame = frame;
        }
        UIView *arrowView = [self.assistantView viewWithTag:4546];
        if (arrowView) {
            CGRect frame = arrowView.frame;
            frame.origin.y = arrowOriginY;
            arrowView.frame = frame;
            ((UIImageView *)arrowView).image = arrowImg;
        }
    }
    [self fadeAssistantViewWithAlpha:alpha];
}

- (void)fadeAssistantViewWithAlpha:(float)alpha
{
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.3];
    [UIView setAnimationDelegate:self];
    self.assistantView.alpha = alpha;
    [UIView commitAnimations];
}

#pragma mark -
#pragma mark Tableview Delegate Methods
- (void)tableViewDidScroll:(UIScrollView *)scrollView
{
    if(self.assistantView.alpha !=0.0)
        [self fadeAssistantViewWithAlpha:0.0];
}

-(void)tableViewDidEndDraggingWithNotDecelerate:(UIScrollView *)scrollView
{
    
}
- (void)tableViewDidEndDecelerating:(UIScrollView *)scrollView
{
    
}

-(void)tableViewWillBeginDragging:(UIScrollView *)scrollView{
    //[[BlockerView shareInstance] stopShowBlockView];
    if (self.alertHeaderView) {
        [self performSelector:@selector(hiddenView:) withObject:alertHeaderView];
    }
}

#pragma mark -
#pragma mark IfengNewsButtonDatasourceAndDelegate input view
-(void)showInputView
{
    self.isReplayComment = NO;
    [self showCommentingView];
}
-(void)showCommentingView{
    if (!self.inputView)
    {
        
        InputView *view = [[InputView alloc] init];
        self.inputView = view;
        view.isReply = self.isReplayComment;
        self.inputView.isShowShare=YES;
        self.inputView.delegate = self;
        self.inputView.commentType=_isStrNotNull(self.commentType)?[self.commentType intValue]:0;
        [self.inputView createContent:nil];
    }
    self.inputView.isReply = self.isReplayComment;
    [self.view addSubview:self.inputView];
    [self.inputView notResign];
}
#pragma mark -
#pragma mark Assiant Events
- (void)copyPressed:(id)sender
{
    [self fadeAssistantViewWithAlpha:0.0];
    NSString *comemntContent = [self.currentCommentSourceData sgrGetStringForKey:@"comment_contents"];
    UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
    [pasteboard setString:comemntContent];
    [[CLGloble sharedInstance] showTieAlertMessage:@"提示" subMessage:@"复制完成"];
    //[BlockerView showAlert:@"复制完成"];
}

- (void)replayPressed:(id)sender
{
    self.assistantView.alpha = 0.0;
    
    if(![[CLGloble sharedInstance] checkOnLine]){
        [[CLGloble sharedInstance] showTieAlertMessage:@"提示" subMessage:@"无网络链接"];
        //[BlockerView showAlert:@"无网络链接"];
        return;
    }
    
    self.isReplayComment = YES;
    [self showCommentingView];
    [self fadeAssistantViewWithAlpha:0.0];
//    [CommentShareCaputreImgHandle createShareViewImage:self.currentCommentSourceData title:self.docTitle parentIndex:self.floorParrentsArrayIndex isOnlyShare:NO];
}

- (void)supportClicked:(id)sender   //表示支持某一个评论
{
    self.assistantView.alpha = 0.0;
    
    if(![[CLGloble sharedInstance] checkOnLine]){
        [[CLGloble sharedInstance] showTieAlertMessage:@"提示" subMessage:@"无网络链接"];
        //[BlockerView showAlert:@"无网络链接"];
        return;
    }
    
//    if([self isSupportedComment:self.selectedIndexPath]){
//        [[CLGloble sharedInstance] showTieAlertMessage:@"提示" subMessage:@"您已支持过了"];
//        //[BlockerView showAlert:@"您已支持过了"];
//        return;
//    }
    [self sendSupportData:self.currentCommentSourceData index:self.selectedIndexPath];
    //[self performSelectorInBackground:@selector(sendSupportData) withObject:nil];
}

- (void)supportClickedWihtIndexPath:(NSDictionary *)dic{
    NSIndexPath *indexPath=[dic sgrGetType:[NSIndexPath class] forKey:@"indexPath"];
    NSDictionary *sourceData=[dic sgrGetDictionaryForKey:@"sourceDic"];
    self.currentCommentSourceData=sourceData;
    self.selectedIndexPath=indexPath;
    [self sendSupportData:sourceData index:indexPath];
    //[self performSelectorInBackground:@selector(sendSupportData) withObject:nil];
}

-(void)sharePressed:(id)sender{
    self.assistantView.alpha = 0.0;
    
    if(![[CLGloble sharedInstance] checkOnLine]){
        [[CLGloble sharedInstance] showTieAlertMessage:@"提示" subMessage:@"无网络链接"];
        //[BlockerView showAlert:@"无网络链接"];
        return;
    }
    NSString *commentStr = @"";
    NSString *uname=@"";
    if(self.currentCommentSourceData && [self.currentCommentSourceData isKindOfClass:[NSDictionary class]])
    {
        if(1==[self.cellLevel integerValue]){
            commentStr = [self.currentCommentSourceData
                          sgrGetStringForKey:@"comment_contents"];
            uname=[self.currentCommentSourceData sgrGetStringForKey:@"uname"];
        }
        else{
            if (2==[self.cellLevel integerValue]) {
                if (0==self.floorParrentsArrayIndex) {
                    commentStr = [self.currentCommentSourceData
                                  sgrGetStringForKey:@"comment_contents"];
                    uname=[self.currentCommentSourceData sgrGetStringForKey:@"uname"];
                }
                else{
                    NSArray *parrents = [self.currentCommentSourceData sgrGetArrayForKey:@"parent"];
                    if (parrents && [parrents count]>self.floorParrentsArrayIndex-1) {
                        NSDictionary *floorCommentDic = [parrents sgrGetDictionaryForIndex:([parrents count]-self.floorParrentsArrayIndex)];
                        commentStr = [floorCommentDic sgrGetStringForKey:@"comment_contents"];
                        uname=[floorCommentDic sgrGetStringForKey:@"uname"];
                    }
                }
            }
            
        }
    }
    commentStr = [commentStr stringByReplacingOccurrencesOfString:@"<br>" withString:@""];
    commentStr = [commentStr stringByReplacingOccurrencesOfString:@"&quot" withString:@""];
    
    NSMutableDictionary *dic=[NSMutableDictionary dictionary];
    [dic sgrSetObject:self.captureImg forKey:@"image"];
    self.captureImg=nil;
    [dic sgrSetObject:[NSString stringWithFormat:@"%@:%@",uname,commentStr] forKey:@"title"];
    [dic sgrSetObject:[NSString stringWithFormat:@"%@:%@",uname,commentStr] forKey:@"content"];
    
    [self openShare:dic];
    
//    CKDocBody *commentDocBody = [[CKDocBody alloc] init];
//    commentDocBody.title = _isStrNotNull(self.docBody.title)?(self.docBody.title):(self.docTitle);
//    commentDocBody.linkType = self.docBody.linkType;
//    commentDocBody.strShareUrl = _isStrNotNull(self.docBody.strShareUrl)?(self.docBody.strShareUrl):(self.wwwUrl);
//    commentDocBody.thumbnail = nil;//self.docBody.thumbnail;
//    commentDocBody.imgArray = nil;//self.docBody.imgArray;
//    commentDocBody.type = DocBodyTypeComments;
//    commentDocBody.documentId = _isStrNotNull(self.docBody.documentId)?(self.docBody.documentId):(self.documentId);
//    commentDocBody.text = [NSString stringWithFormat:@"网友评论:%@",commentStr];
//    commentDocBody.isComment = YES;
//    [CommentShareCaputreImgHandle createShareViewImage:self.currentCommentSourceData title:self.docTitle parentIndex:self.floorParrentsArrayIndex isOnlyShare:YES];
//    commentDocBody.captureImg=[IFShareDelegateObject sharedInstance].currentShareImage;
//    [CTShareController shareWithRootView:[cactusAppDelegate ctWindow] andShareData:commentDocBody];
    
    return;
}

- (void)replayDocPressed:(id)sender
{
    if(![[CLGloble sharedInstance] checkOnLine]){
        //[BlockerView showAlert:@"无网络链接"];
        [[CLGloble sharedInstance] showTieAlertMessage:@"提示" subMessage:@"无网络链接"];
        return;
    }
    
    [self fadeAssistantViewWithAlpha:0.0];
    self.isReplayComment = NO;
    [self showCommentingView];
}

- (void)sendSupportData:(NSDictionary *)dic index:(NSIndexPath *)indexPath
{
    
   // __weak typeof(self) me=self;
    [[CLComentDataModel sharedInstance] support:self.commentTopicId
                                      commentID:[dic sgrGetStringForKey:@"comment_id"]
                                          block:^(BOOL success, NSString *responseStr) {
                                              if(success){
                                                  [[CLGloble sharedInstance] showTieAlertMessage:@"提示"
                                                                                      subMessage:@"支持成功"];
                                                  
                                                  [self.supportedIndexPaths sgrAddObject:self.selectedIndexPath];
                                                 CommentCommonCell *clickedCell = (CommentCommonCell *)[self.ctContent.table cellForRowAtIndexPath:self.selectedIndexPath];
                                                         [clickedCell supportComment];
                                              }else{
                                                  [[CLGloble sharedInstance] showTieAlertMessage:@"提示"
                                                                                      subMessage:@"支持失败"];
                                              }
                                          }];
    
//    NSString *urlStr = [[Globle shareInstance] getAbsolutlyUrlById:@"commentSupport"];
//    NSString *docID = (NSString *)[self.currentCommentSourceData sgrFGetStringforKey:@"comment_id"];
//    NSString *sourceDocUrl = self.docUrl?self.docUrl:self.wwwUrl;
//    NSString *timeStamp = [NSString stringWithFormat:@"%f",[[NSDate date] timeIntervalSince1970]];
//    NSString *comleteUrlStr = [NSString stringWithFormat:urlStr,docID,sourceDocUrl,timeStamp];
//    
//    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:comleteUrlStr]];
//    NSData *data = [NSURLConnection sendSynchronousRequest:request
//                                         returningResponse:nil
//                                                     error:nil];
//    NSString *result = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
//    if(result && [result isEqualToString:@"1"]){
//        [BlockerView showAlert:@"支持成功"];
//        [self.supportedIndexPaths sgrAddObject:self.selectedIndexPath];
//        CommentCommonCell *clickedCell = (CommentCommonCell *)[self.ctContent cellForRowAtIndexPath:self.selectedIndexPath];
//        [clickedCell supportComment];
//    }
//    else
//        [BlockerView showAlert:@"支持失败"];
//    [[NSRunLoop currentRunLoop] run];
}

- (BOOL)isSupportedComment:(NSIndexPath *)currentIndexPath
{
    if(!self.supportedIndexPaths){
        NSMutableArray *indexPaths = [[NSMutableArray alloc] init];
        self.supportedIndexPaths = indexPaths;
        
        return NO;
    }
    
    for(NSIndexPath *indexPath in self.supportedIndexPaths)
    {
        if([indexPath compare:currentIndexPath] == NSOrderedSame)
            return YES;
    }
    return NO;
}

- (void)startLoadData
{
    [self.waitingView startAnimating];
}

- (void)finishedLaodData
{
    [self.waitingView stopAnimating];
}

- (void)nameTapWithData:(NSDictionary *)dic withIndexPath:(NSIndexPath *)indexPath
{
    NSString* face = [dic sgrGetStringForKey:@"userFace"];
    NSString* ext2 = [dic sgrGetStringForKey:@"ext2"];
    NSString* uname = [dic sgrGetStringForKey:@"uname"];
    
    if(_isStrNULL(ext2)){
        
        return;
    }
    
   
}

@end
